{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
	<article>
		<div class="top-title">
			<dl>
				<dt><h1>{{.title}}</h1></dt>
				<dd>&nbsp;</dd>
			</dl>
		</div>
		<!-- <div class="nav1">
			<ul>
				<a href="works_index.html" class="no"><li>全部产品</li></a>
				<a href="works_index.html"><li>产品分类</li></a>
				<a href="works_index.html"><li>产品分类</li></a>
				<a href="works_index.html"><li>产品分类</li></a>
				<a href="works_index.html"><li>产品分类</li></a>
				<a href="works_index.html"><li>产品分类</li></a>
			</ul>
		</div> -->
		<div class="content">
			<div class="release">
				<dl>
					<dt><i class="iconfont">&#xe649;</i> <b>产品规格说明</b><br>
						请在发布产品时上传缩略图设计为正方形，防止前台显示图片变形<mark>图片变形</mark> 。上传图片不要大于2M<br>
						<p> <mark>未审核</mark>的产品将不会在小程序中显示,先按是否推荐对产品排序,然后排序数字越大产品位置越靠前</p>
					</dt>
					<dd><a href="/admin/product/spec_add?pid={{.info.id}}"><button type="button" class="button">添加规格</button></a></dd>
				</dl>
			</div>	
			{{range .info.spec}}
			<form action="" method="get" autocomplete="on" class="form" id="mt_product_spec{{.id}}">
				<table class="table1">
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td rowspan="3" colspan="2" class="center"><img src="{{.pathname}}" class="uppic img-3"></td>
						<td class="genre">规格名称</td>
						<td>
							{{.title}}
						</td>
						<td class="genre">规格价格</td>
						<td>
							{{.price}}
						</td>
						<td class="genre">操作</td>
						<td>
							<a href="/admin/product/spec_add?id={{.id}}" class="tz"> 编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="tz del" table="mt_product_spec" data-id="{{.id}}">删除 </a>
						</td>
					</tr>
					<tr>
						<td class="genre">装箱数</td>
						<td>
							{{.number}}
						</td>
						<td class="genre">库存</td>
						<td>
							{{.inventory}}
						</td>
						<td class="genre">佣金</td>
						<td>
							{{.promote}}
						</td>
					</tr>
					<tr>
						<td class="genre">排序</td>
						<td>
							{{.sort}}
						</td>
						<td class="genre">添加时间</td>
						<td>
							{{.addtime}}
						</td>
						<td class="genre">修改时间</td>
						<td>
							{{.modifytime}}
						</td>
					</tr>
					<tr>
						<td class="genre">简介</td>
						<td colspan="7">
							{{.info.description}}
						</td>
					</tr>
					<tr class="tjcs">
						<td class="genre" colspan="7">参数</td>
						<td><a class="tz p_add" sid="{{.id}}">添加参数</a></td>
					</tr>
					{{range .parameter}}
					<tr id="mt_product_parameter{{.id}}">
						<td class="genre">参数名</td>
						<td>
							{{.key}}
						</td>
						<td class="genre">参数值</td>
						<td>
							{{.value}}
						</td>
						<td class="genre">排序</td>
						<td>
							{{.sort}}
						</td>
						<td class="genre">操作</td>
						<td>
							<a data-id="{{.id}}" data-sid="{{.sid}}" data-sort="{{.sort}}" data-value="{{.value}}" data-key="{{.key}}" class="tz p_edit"> 编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="tz del" table="mt_product_parameter" data-id="{{.id}}">删除 </a>
						</td>
					</tr>
					{{end}}
				</table>
			</form>
			<div class="release" style="margin-top: 30px;">
			</div>
			{{end}}
			<div class="release">
				<dl>
					<dt><i class="iconfont">&#xe649;</i> <b>{{.title}}说明</b><br>
						请在发布产品时上传缩略图设计为正方形，防止前台显示图片变形<mark>图片变形</mark> 。上传图片不要大于2M<br>
						<p> <mark>未审核</mark>的产品将不会在小程序中显示,先按是否推荐对产品排序,然后排序数字越大产品位置越靠前</p>
					</dt>
				</dl>
			</div>
			<form action="" method="get" autocomplete="on" class="form">

				<table class="table1">
					<!-- 控制表格宽度  横向合并 colspan="1"  竖向合并 rowspan="3" -->
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td class="genre">产品标题</td>
						<td colspan="3">
							{{.info.title}}
						</td>
						<td class="genre">所属品牌</td>
						<td colspan="3">
							{{.info.bname}}
						</td>
					</tr>
					<tr>
						<td class="genre">产品主平台栏目</td>
						<td colspan="3">
							{{.info.cname}}
						</td>
						{{if .info.gname}}
						<td class="genre">店铺栏目</td>
						<td colspan="3">
							{{.info.gname}}
						</td>
						{{end}}
					</tr>
					<tr>
						<td class="genre">关键词</td>
						<td colspan="7">
							{{range .keywords}}
							<mark>{{.title}}、</mark>
							{{end}}
						</td>
					</tr>
					<tr>
						<td class="genre">排序</td>
						<td colspan="3">
							{{.info.sort}}
						</td>
						<td class="genre">点击数</td>
						<td colspan="3">
							{{.info.click}}
						</td>
					</tr>
					<tr>
						<td class="genre">审查</td>
						<td colspan="3">
							{{if .info}}{{if eq .info.censoring "0"}}未审查{{else}}已审查{{end}}{{end}}
						</td>
						<td class="genre">推荐</td>
						<td colspan="3">
							{{if .info}}{{if eq .info.recommend "0"}}未推荐{{else}}已推荐{{end}}{{end}}
						</td>
					</tr>
					<tr>
						<td class="genre">缩略图</td>
						<td colspan="7">
							<div class="thumbnail">
								<dl><dt><img src="{{if .info.pathname}}{{.info.pathname}}{{else}}/static/img/admin/uppic.png{{end}}" class="uppic"></dt><dd>缩略图</dd></dl>
								{{range .picture}}
								<dl><dt><img src="{{.pathname}}" class="uppic"></dt><dd>轮播图</dd></dl>
								{{end}}
							</div>
						</td>
					</tr>
					{{if .vname}}
					<tr>
						<td class="genre">视频</td>
						<td colspan="7">
							<video src="{{.vname}}"></video>
						</td>
						
					</tr>
					{{end}}
					<tr>
						<td class="genre">简介</td>
						<td colspan="7">
							{{.info.description}}
						</td>
					</tr>
					<tr>
						<td colspan="8">{{if .info.content}}{{str2html .info.content}}{{end}}</td>
					</tr>
				</table>
			</form>
		</div>
<div class="mask">
	<div class="mask-content">
		<form id="parameter">
			<table class="table1">
				<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
				<tr>
					<td class="genre" colspan="2">参数名</td>
					<td colspan="6">
						<input type="text" class="input95" placeholder="请输入参数名！" name="key">
					</td>
				</tr>
				<tr>
					<td class="genre" colspan="2">参数值</td>
					<td colspan="6">
						<input type="text" class="input95" placeholder="请输入参数值！" name="value">
					</td>
				</tr>
				<tr>
					<td class="genre" colspan="2">排序</td>
					<td colspan="6">
						<input type="text" class="input95" placeholder="请输入排序" name="sort" value="0">
					</td>
				</tr>
			</table>
			<input type="hidden" name="id">
			<input type="hidden" name="sid">
		</form>
		<p id="tip"></p>
		<div class="mask-form">
			<dl>
				<dt>
					<button id="qr">保存</button>
					<button id="cancle">取消</button>
				</dt>
				<dd>
				</dd>
			</dl>
		</div>
	</div>
</div>
	</article>
</section>

<footer><!-- 系统监控内容 --></footer>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script>
	$('.p_add').click(function(){
		$('.mask').show()
		$('input[name="sid"]').val($(this).attr('sid'))
	})
	$('.p_edit').click(function(){
		$('.mask').show()
		$('input[name="sid"]').val($(this).attr('data-sid'))
		$('input[name="id"]').val($(this).attr('data-id'))
		$('input[name="sort"]').val($(this).attr('data-sort'))
		$('input[name="key"]').val($(this).attr('data-key'))
		$('input[name="value"]').val($(this).attr('data-value'))
	})
	$('#cancle').click(function(){
		$('.mask').hide()
	})
	$('#qr').click(function(){
		if (!$('input[name="key"]').val()){
			$('#tip').html('请输入参数名！');
			return false;
		}
		if (!$('input[name="value"]').val()){
			$('#tip').html('请输入参数值！');
			return false;
		}
		var form=$('#parameter').serialize()
		$.ajax({
			url:"/admin/product/parameter",
			data:form,
			type:'post',
			success:function(res){
				if (res==1){
					$('.mask').hide()
					var id=$('input[name="id"]').val()
					var sort=$('input[name="sort"]').val()
					if (!sort){
						sort="0"
					}
					if(!id){
					var html=`<tr id="mt_product_parameter`+id+`">
							<td class="genre">参数名</td>
							<td>
								`+$('input[name="key"]').val()+`
							</td>
							<td class="genre">参数值</td>
							<td>
								`+$('input[name="value"]').val()+`
							</td>
							<td class="genre">排序</td>
							<td>
								`+$('input[name="sort"]').val()+`
							</td>
							<td class="genre">操作</td>
							<td>
								<a data-id="`+id+`" data-sid="`+$('input[name="sid"]').val()+`" data-sort="`+sort+`" data-value="`+$('input[name="value"]').val()+`" data-key="`+$('input[name="key"]').val()+`" class="tz p_edit"> 编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="tz del" table="mt_product_parameter" data-id="`+id+`">删除 </a>
							</td>
						</tr>`
						var sid=$('input[name="sid"]').val();
						$('#mt_product_spec'+sid).find('.tjcs').after(html)
					}else{
						var html=`<td class="genre">参数名</td>
							<td>
								`+$('input[name="key"]').val()+`
							</td>
							<td class="genre">参数值</td>
							<td>
								`+$('input[name="value"]').val()+`
							</td>
							<td class="genre">排序</td>
							<td>
								`+$('input[name="sort"]').val()+`
							</td>
							<td class="genre">操作</td>
							<td>
								<a data-id="`+id+`" data-sid="`+$('input[name="sid"]').val()+`" data-sort="`+sort+`" data-value="`+$('input[name="value"]').val()+`" data-key="`+$('input[name="key"]').val()+`" class="tz p_edit"> 编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="tz del" table="mt_product_parameter" data-id="`+id+`">删除 </a>
							</td>`
						$('#mt_product_parameter'+id).html(html)
					}
					$('input[name="id"]').val('')
					$('input[name="sid"]').val('')
					$('input[name="key"]').val('')
					$('input[name="value"]').val('')
					$('input[name="sort"]').val('')
				}else{
					window.wxc.xcConfirm("保存失败,请重试!","error")
				}
			}
		})
	})
	$('.del').click(function(){
		var id=$(this).attr('data-id');
		var table=$(this).attr('table')
		wxc.xcConfirm("您确定要删除这条数据吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/del',
				data:{table:table,id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('删除成功');
						$('#'+table+id).css('display','none');
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
</script>
</body>
</html>
